import { ITrade } from './trade'
import { ICursorPagination, IPagination } from './pagination'
import { IQueryParams } from './queryParams'
import { IOption } from './common'

export class PostRiskEventScheme {
  eventID: number
  insCode: string
  category: string
  storeScore: number
  schemeCode: string
  schemeName: string
  intStoreCode: string
  handleStatus: string
  remark: string
  platform: string
  rules: PostRiskEventRule[]
  createdAt: string
  updatedAt: string
  status: 'normal' | 'freeze'
  score: number

  constructor(code?: string, name?: string) {
    this.schemeCode = code
    this.schemeName = name
  }
}

export interface IPostRiskEventSchemePagination extends ICursorPagination {
  data: PostRiskEventScheme[]
}

export interface IPostRiskEventQueryParams extends IQueryParams {
  schemeCode?: string
  schemeName?: string
  createdAtFrom?: string
  createdAtTo?: string
}

export interface IPostRiskEventDetailQueryParams {
  eventID: string
  intStoreCode: string
}

export interface IPostRiskEventRuleTradeQueryParams extends IQueryParams {
  eventRuleID: number
  eventId: number
}

export class PostRiskEventRule {
  createdTime?: string
  updatedTime?: string
  schemeCode?: string
  threshold: number
  eventRuleID: string
  thresholdDes: string
  mode: string
  ruleId: number
  score: number
  ruleType: string
  ruleDes: string
}

export interface IPostRiskEventRuleTrade extends ITrade {
  cardNum: string,
  remark: string,
  status?: string,
  eventTransID: string
}

export interface IPostRiskEventRuleTradePagination extends IPagination {
  data: IPostRiskEventRuleTrade[]
}

export interface IRiskControlBiz {
  biz: string
  bizId: string
  name: string
  nameEn: string
}

export enum RiskRuleModeEnum {
  Trade = '00',
  Day = '01',
  Month = '30',
  Refund = 'refund',
}

export const RiskRuleModeMap = {
  '00': 'RISK_CTRL_RULE_MODE.SINGLE',
  '01': 'RISK_CTRL_RULE_MODE.SINGLE_DAY',
  30: 'RISK_CTRL_RULE_MODE.SINGLE_MONTH',
  refund: 'RISK_CTRL_RULE_MODE.REFUND',
}

export const postRiskEventStatusMap = {
  P: 'RISK.EVENT.STATUS.PENDING',
  E: 'RISK.EVENT.STATUS.EXAMINED',
  R: 'RISK.EVENT.STATUS.RELEASED',
}
